home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / skk / skk-isearch.el.z / skk-isearch.el
Encoding:
Text File  |  1998-05-21  |  20.2 KB  |  569 lines

  1. ;;; isearch mode for skk with emacs 19.
  2.  
  3. ;; $Id: skk-isearch.el,v 1.3 1997/09/16 08:56:20 mrt Exp $
  4.  
  5. ;; Copyright (C) 1994, 1995, 1996, 1997
  6. ;; Enami Tsugutomo <enami@ba2.so-net.or.jp>
  7.  
  8. ;; This program is free software; you can redistribute it and/or modify
  9. ;; it under the terms of the GNU General Public License as published by
  10. ;; the Free Software Foundation; either versions 2, or (at your option)
  11. ;; any later version.
  12.  
  13. ;; This program is distributed in the hope that it will be useful
  14. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ;; GNU General Public License for more details.
  17.  
  18. ;; You should have received a copy of the GNU General Public License
  19. ;; along with SKK, see the file COPYING.  If not, write to the Free
  20. ;; Software Foundation Inc., 59 Temple Place - Suite 330, Boston,
  21. ;; MA 02111-1307, USA.
  22.  
  23. ;; skk-isearch-initial-mode examine the variable of skk before calling
  24. ;; skk-mode.
  25. (require 'skk-foreword)
  26. (require 'skk-vars)
  27.  
  28. ;;
  29. ;; variables
  30. ;;
  31. (defvar skk-isearch-incomplete-message "" "incomplete isearch message")
  32. (defvar skk-isearch-working-buffer " *skk-isearch*"
  33.   "work buffer for skk isearch.")
  34.  
  35. ;; (setq skk-isearch-mode-map nil)
  36. ;; (lookup-key skk-isearch-mode-map " ")
  37. (defvar skk-isearch-mode-map nil
  38.   "Keymap for skk isearch mode.  This map should be derived from
  39. isearch-mode-map.")
  40.  
  41. ;;;###skk-autoload
  42. (defvar skk-isearch-whitespace-regexp "\\(\\s \\|[ \t\n\r\f]\\)*")
  43.  
  44. (defvar skk-isearch-overriding-local-map
  45.   (cond (skk-xemacs
  46.      'overriding-terminal-local-map)
  47.     ((and (boundp 'emacs-major-version)
  48.           (or (> emacs-major-version 19)
  49.           (and (= emacs-major-version 19) 
  50.                (>= emacs-minor-version 29))))
  51.      ;; GNU Emacs version 19.29, 19.30 and 19.31 uses this in isearch.el.
  52.      'overriding-terminal-local-map)
  53.     ;; GNU Emacs version 19.22 .. 19.28 uses this in isearch.el.
  54.     ((string-match "^19\\.2[2-8]" emacs-version) 'overriding-local-map))
  55.   "Variable holding overrinding local map used in isearch-mode.")
  56.  
  57. (defvar skk-isearch-breakup-string-function
  58.   (cond ((fboundp 'string-to-char-list)
  59.      ;; Mule 2.3 or its ancestor defines `string-to-char-list'.
  60.      'string-to-char-list)
  61.     ((fboundp 'string-to-list)
  62.      ;; delta version of Mule merged Emacs currently defines
  63.      ;; `string-to-list'.
  64.      'string-to-list)
  65.     (t (error "No appropriate function as: %s"
  66.           'skk-isearch-breakup-string-function)))
  67.   "Function to breakup STRING into list of characters.")
  68.  
  69. (defvar skk-isearch-breakable-character-p-function
  70.   (cond ((fboundp 'char-category-set)
  71.      (function (lambda (char)
  72.              ;; see emacs/lisp/fill.el how the category `|' is
  73.              ;; treated.
  74.              (aref (char-category-set char) ?|))))
  75.     ((boundp 'word-across-newline)
  76.      (function (lambda (char)
  77.              ;; (let ((lc (char-leading-char char)))
  78.              ;;   (or (= lc lc-jp) (= lc lc-cn)))
  79.              (string-match (char-to-string char)
  80.                    word-across-newline))))
  81.     (t (error "No appropriate function as: %s"
  82.           'skk-isearch-breakable-character-p-function)))
  83.   "Function to test if we can insert a newline around the CHAR when filling.")
  84.  
  85. (defvar skk-isearch-use-previous-mode nil
  86.   "*If non-nil, search mode will be same as the last search mode for the
  87. previous search in the buffer.")
  88.  
  89. ;; suggested by Yoshiyuki Kondo, 1991.6.19.
  90. ;; modified by Mikio Nakajima, 1995.5.30
  91. (defvar skk-isearch-start-mode nil
  92.   "*Specifies the search mode when isearch is called.
  93. This variable is valid only when `skk-isearch-use-previous-mode' is nil.
  94. If nil, it means that if skk-mode has been called in this buffer, same as
  95. the mode of the buffer, otherwise perform ascii search.  If `ascii', perfrom
  96. ascii search.  If `kana' or `hirakana' -> hira kana search.  If `eiji',
  97. perform zenkaku eiji (i.e. JIS X0208 alphabet) search.")
  98.  
  99. (defvar skk-isearch-mode nil
  100.   "Current search mode.  0 -> hira kana search.  1 -> kata kana search.
  101. 2 -> zenkaku eiji (i.e. JIS X0208 alphabet) search.  3 -> ascii search.")
  102.  
  103.  
  104. (defsubst skk-isearch-set-working-buffer ()
  105.   "Set current buffer to the working buffer for skk isearch."
  106.   (set-buffer (get-buffer-create skk-isearch-working-buffer)))
  107.  
  108. ;;
  109. ;; interface to skk.el
  110. ;;
  111. (defsubst skk-isearch-turn-off-skk-mode ()
  112.   "Turn off skk mode."
  113.   (skk-mode 0) )
  114.  
  115. (defsubst skk-isearch-turn-on-skk-mode ()
  116.   "Turn on skk mode."
  117.   (skk-mode 1) )
  118.  
  119. (defsubst skk-isearch-conversion-active-p ()
  120.   "Non-nil if skk conversion is active."
  121.   skk-henkan-on )
  122.  
  123. (defsubst skk-isearch-conversion-start ()
  124.   "Point where conversion is start.  Includes skk marker."
  125.   (- skk-henkan-start-point skk-kanji-len))
  126.  
  127. (defsubst skk-isearch-skk-kakutei ()
  128.   "Perform kakutei."
  129.   (skk-kakutei) )
  130.  
  131. (defsubst skk-isearch-skk-hirakana-mode-p ()
  132.   "Non-nil if skk is hirakana input mode."
  133.   (and (not skk-katakana) skk-j-mode) )
  134.  
  135. (defsubst skk-isearch-skk-turn-on-hirakana-mode ()
  136.   "Set current skk mode to hirakana input mode."
  137.   (skk-j-mode-on) )
  138.  
  139. (defsubst skk-isearch-skk-katakana-mode-p ()
  140.   "Non-nil if skk is katakana input mode."
  141.   (and skk-j-mode skk-katakana) )
  142.  
  143. (defsubst skk-isearch-skk-turn-on-katakana-mode ()
  144.   "Set current skk mode to katakana input mode."
  145.   (skk-j-mode-on 'katakana) )
  146.  
  147. (defsubst skk-isearch-skk-jix0208-latin-mode-p ()
  148.   "Non-nil if skk is zenkaku (jisx0208 latin) input mode."
  149.   skk-zenkaku-mode )
  150.  
  151. (defsubst skk-isearch-skk-turn-on-jix0208-latin-mode ()
  152.   "Set current skk mode to zenkaku (jisx0208 latin) input mode."
  153.   (skk-zenkaku-mode-on) )
  154.  
  155. (defsubst skk-isearch-skk-turn-on-latin-mode ()
  156.   "Set current skk mode to normal latin input mode."
  157.   (skk-ascii-mode-on) )
  158.  
  159. ;; Override the function in skk-isearch.el.  I hope the
  160. ;; skk-kana-input would be rewritten without using while
  161. ;; read-char loop...
  162. (defun skk-isearch-message ()
  163.   "Show isearch message."
  164.   ;; `prefix' is dynmaic variable in skk-kana-input.
  165.   (skk-isearch-incomplete-message
  166.    (if (boundp 'prefix)
  167.        prefix
  168.      (char-to-string last-command-char))))
  169.  
  170. (defun skk-isearch-current-mode ()
  171.   "Return the symbolic current mode of skk for skk-isearch."
  172.   (cond ((not skk-mode) nil)
  173.     ((skk-isearch-skk-katakana-mode-p) 'katakana)
  174.     ((skk-isearch-skk-hirakana-mode-p) 'hiragana)
  175.     ((skk-isearch-skk-jix0208-latin-mode-p) 'jisx0208-latin)
  176.     (t 'latin)))
  177.  
  178. (defun skk-isearch-set-initial-mode (mode)
  179.   "Set up the initial condition according to given symbolic MODE.
  180. The MODE should be canonical."
  181.   ;; following code is highly depends on internal of skk.
  182.   ;; (skk-isearch-turn-on-skk-mode)
  183.   ;; (skk-isearch-skk-kakutei)
  184.   (cond ((eq mode 'hiragana) (skk-isearch-skk-turn-on-hirakana-mode))
  185.     ((eq mode 'katakana) (skk-isearch-skk-turn-on-katakana-mode))
  186.     ((eq mode 'jisx0208-latin)
  187.      (skk-isearch-skk-turn-on-jix0208-latin-mode))
  188.     ((eq mode 'latin) (skk-isearch-skk-turn-on-latin-mode))
  189.     ((not mode) (skk-isearch-turn-off-skk-mode))
  190.     ;; shouldn't happen.
  191.     (t (error "unknown skk-isearch-mode %s" mode))))
  192.  
  193. ;;
  194. ;; functions for hooks.
  195. ;;
  196. ;; 1. always invoke skk isearch.
  197. ;; (add-hook 'isearch-mode-hook 'skk-isearch-mode-setup)
  198. ;; (add-hook 'isearch-mode-end-hook 'skk-isearch-mode-cleanup)
  199. ;; 2. invoke only if skk-mode is on.
  200. ;; (add-hook 'isearch-mode-hook
  201. ;;           (function (lambda ()
  202. ;;             (and (boundp 'skk-mode) skk-mode
  203. ;;                  (skk-isearch-mode-setup)))))
  204. ;; (add-hook 'isearch-mode-end-hook
  205. ;;         (function (lambda ()
  206. ;;             (and (boundp 'skk-mode) skk-mode
  207. ;;                  (skk-isearch-mode-cleanup)))))
  208. ;; 3. invoke if current buffer has japanese characters.
  209. ;; ...
  210.  
  211. (defvar skk-isearch-mode-canonical-alist
  212.   '((hiragana . 0) (katakana . 1) (jisx0208-latin . 2) (latin . 3))
  213.   "List of dot pair, (SYMBOL . NUMBER).
  214. The SYMBOL is canonical skk mode, and NUMBER is its numerical representation.")
  215.  
  216. (defvar skk-isearch-mode-alias-alist
  217.   '((hirakana . hiragana) (kana . hiragana)
  218.     (eiji . jisx0208-latin)
  219.     (ascii . latin))
  220.   "List of dot pair, (ALIAS . CANONICAL).  The both ALIAS and CANONICAL should
  221. be symbol.  ALIAS can be used as an alias of CANONICAL.  CANONICAL should be
  222. found in `skk-isearch-mode-canonical-alist'.")
  223.  
  224. ;; (makunbound 'skk-isearch-mode-string-alist)
  225. (defvar skk-isearch-mode-string-alist
  226.   '((hiragana . "[$B$+(B] ") (katakana . "[$B%+(B] ")
  227.     (jisx0208-latin . "[$B1Q(B] ") (latin . "[aa] ") (nil . "[--] "))
  228.   "Alist of (MODE-SYMBOL . PROMPT-STRING).  MODE-SYMBOL is a symbol
  229. indicates canonical mode of skk for skk-isearch.  PROMPT-STRING is a string
  230. used in prompt to indicates current mode of skk for skk-isearch.")
  231.  
  232. (defun skk-isearch-symbolic-mode (mode)
  233.   "Return symbolic skk isearch mode for given numerical MODE."
  234.   (car (rassq mode skk-isearch-mode-canonical-alist)))
  235.  
  236. (defun skk-isearch-numerical-mode (mode)
  237.   "Return numerical skk isearch mode for given symbolic MODE."
  238.   (cdr (assq mode skk-isearch-mode-canonical-alist)))
  239.  
  240. (defun skk-isearch-mode-string ()
  241.   "Return the current skk mode string for prompting."
  242.   (with-current-buffer (get-buffer-create skk-isearch-working-buffer)
  243.     (cdr (assq (skk-isearch-current-mode) skk-isearch-mode-string-alist))))
  244.  
  245. (defun skk-isearch-current-numerical-mode ()
  246.   "Return the symbolic skk isearch mode according to the current skk
  247. internal condition."
  248.   (skk-isearch-numerical-mode (or (skk-isearch-current-mode) 'latin)))
  249.  
  250. (defun skk-isearch-canonical-start-mode (mode)
  251.   "Canonicalize the symbolic skk isearch MODE."
  252.   ;; alias, canonical, or error.
  253.   (cond ((cdr (assq mode skk-isearch-mode-alias-alist)))
  254.     ((skk-isearch-numerical-mode mode) mode)
  255.     (t (error "Unknown skk-isearch-start-mode: %s" mode))))
  256.  
  257. (defvar skk-isearch-initial-mode-when-skk-mode-disabled 'latin
  258.   "*Symbol indicates the mode to use as initial mode for skk-isearch when
  259. skk is turned off in the current buffer.")
  260.  
  261. (defun skk-isearch-initial-mode ()
  262.   "Return the symbolic mode name of skk-isearch used to initialize working
  263. buffer."
  264.   (cond ((and skk-isearch-use-previous-mode skk-isearch-mode)
  265.      ;; use the mode when last isearch is done.  note that the
  266.      ;; `skk-isearch-mode' is numerical, so convert it to symbolic
  267.      ;; mode.
  268.      (skk-isearch-symbolic-mode skk-isearch-mode))
  269.     (skk-isearch-start-mode
  270.      ;; always start with the specified mode.
  271.      ;; `skk-isearch-start-mode' is symbolic.
  272.      (skk-isearch-canonical-start-mode skk-isearch-start-mode))
  273.     ;; guess the current buffer.  note that if skk-mode is off,
  274.     ;; skk-isearch-current-mode returns symbol `nil' and control
  275.     ;; falls through to next cond clause.
  276.     ((skk-isearch-current-mode))
  277.     ;; skk-mode is off in this buffer.
  278.     (t skk-isearch-initial-mode-when-skk-mode-disabled)))
  279.  
  280. (defun skk-isearch-initialize-working-buffer ()
  281.   "Initialize the current buffer as working buffer for skk isearch.
  282. More precicely, turn on skk-mode, put into kana mode, make sure
  283. kakutei'ed and erase the buffer contents."
  284.   (skk-isearch-turn-on-skk-mode)
  285.   (skk-isearch-skk-kakutei)
  286.   (erase-buffer))
  287.  
  288. ;;;###autoload
  289. (defun skk-isearch-mode-setup ()
  290.   "hook function called when skk isearch begin."
  291.   ;; setup working buffer.  initial skk mode for isearch should be
  292.   ;; determined in the original buffer and set in working buffer.
  293.   (let ((initial (skk-isearch-initial-mode)))
  294.     (with-current-buffer (get-buffer-create skk-isearch-working-buffer)
  295.       (skk-isearch-initialize-working-buffer)
  296.       (skk-isearch-set-initial-mode initial)))
  297.   ;; setup variables and keymap
  298.   (set skk-isearch-overriding-local-map skk-isearch-mode-map)
  299.   (setq skk-isearch-incomplete-message ""
  300.     ;; set skk-isearch-message non-nil to call skk-isearch-message.
  301.     skk-isearch-message "")
  302.   (skk-isearch-mode-message)
  303.   (skk-isearch-incomplete-message))
  304.  
  305. ;;;###autoload
  306. (defun skk-isearch-mode-cleanup ()
  307.   "Hook function called when skk isearch is done."
  308.   ;; remember the current skk mode for next use.
  309.   (and skk-isearch-use-previous-mode
  310.        (setq skk-isearch-mode
  311.          (with-current-buffer (get-buffer-create skk-isearch-working-buffer)
  312.            (skk-isearch-current-numerical-mode))))
  313.   ;; reset the overrinding-local-map.
  314.   (set skk-isearch-overriding-local-map nil)
  315.   (setq skk-isearch-message nil
  316.     skk-isearch-last-mode-string ""
  317.     skk-isearch-last-mode-regexp ""))
  318.  
  319. ;;; for backward compatibility
  320. (defalias 'skk-isearch-forward 'isearch-forward)
  321. (defalias 'skk-isearch-forward-regexp 'isearch-forward-regexp)
  322. (defalias 'skk-isearch-backward 'isearch-backward)
  323. (defalias 'skk-isearch-backward-regexp 'isearch-backward-regexp)
  324.  
  325. (defun skk-isearch-incomplete-message (&optional prefix)
  326.   "Show message when when kana kanji convertion is progress.
  327. Optional argument PREFIX is apppended if given."
  328.   (let ((isearch-message (concat isearch-message
  329.                  skk-isearch-incomplete-message prefix)))
  330.     (isearch-message)))
  331.  
  332. ;;
  333. ;; define keymap
  334. ;;
  335.  
  336. ;; XXX should be more generic
  337. (defun skk-isearch-setup-keymap (map)
  338.   ;; printable chars.
  339.   (let ((c ?\040))
  340.     (while (< c ?\177)
  341.       (define-key map (char-to-string c) 'skk-isearch-wrapper)
  342.       (setq c (1+ c))))
  343.  
  344.   ;; control chars for skk.
  345.   (define-key map "\C-g" 'skk-isearch-keyboard-quit)
  346.   (define-key map "\C-j" 'skk-isearch-newline)
  347.   (define-key map "\C-m" 'skk-isearch-exit)
  348.   (define-key map "\177" 'skk-isearch-delete-char)
  349.  
  350.   ;; C-x map for skk.
  351.   (define-key map "\C-x" (make-sparse-keymap))
  352.   (define-key map [?\C-x t] 'isearch-other-control-char)
  353.   (define-key map "\C-x\C-j" 'skk-isearch-skk-mode)
  354.   map)
  355.  
  356. (or skk-isearch-mode-map
  357.     (if skk-xemacs
  358.         (progn
  359.           (setq skk-isearch-mode-map (skk-isearch-setup-keymap (make-keymap)))
  360.           (set-keymap-parents skk-isearch-mode-map isearch-mode-map) )
  361.       (setq skk-isearch-mode-map
  362.             (skk-isearch-setup-keymap (cons 'keymap isearch-mode-map)) )))
  363.  
  364.  
  365. ;;
  366. ;; wrapper functions
  367. ;;
  368.  
  369. (defun skk-isearch-redo-function ()
  370.   "Execute the command of given key sequence in skk environment."
  371.   ;; with saving value of old binding.
  372.   (let ((local-map (symbol-value skk-isearch-overriding-local-map)))
  373.     (unwind-protect
  374.     (progn
  375.       ;; temporarily disable the overriding-local-map.  this
  376.       ;; should be done in ther buffer isearch is performed, i.e.,
  377.       ;; before calling skk-isearch-set-working-buffer.
  378.       (set skk-isearch-overriding-local-map nil)
  379.       ;; don't change the current buffer during save/restore the
  380.       ;; overriding-local-map, because it is buffer local in some
  381.       ;; version of emacs.
  382.       (with-current-buffer (get-buffer-create skk-isearch-working-buffer)
  383.         ;; listify this-command-keys.  this works only if it is
  384.         ;; string.
  385.         (setq unread-command-events
  386.           (append (if (= (length (this-command-keys)) 0)
  387.                   (list last-command-event)
  388.                 (this-command-keys) )
  389.               nil ))
  390.         (condition-case error
  391.         ;; setup last-command-event and this-command because
  392.         ;; some command refers them.
  393.         (let* ((keys (read-key-sequence nil))
  394.                (this-command (key-binding keys)))
  395.           (setq last-command-event (aref keys (1- (length keys))))
  396.           (command-execute this-command))
  397.           (quit (signal (car error) (cdr error)))
  398.           (error (signal (car error) (cdr error)))))
  399.       (skk-isearch-mode-message))
  400.       (set skk-isearch-overriding-local-map local-map))))
  401.  
  402. (defun skk-isearch-search-string ()
  403.   "Return the string to be searched.
  404. If the conversion is progress and no string is fixed, just return nil."
  405.     (with-current-buffer (get-buffer-create skk-isearch-working-buffer)
  406.       (prog1
  407.       (cond ((skk-isearch-conversion-active-p)
  408.          (let ((start (skk-isearch-conversion-start)))
  409.            ;; is there fixed string?
  410.            (if (/= start 1)
  411.                (prog1
  412.                (buffer-substring 1 start)
  413.              (delete-region 1 start)))))
  414.         ;; whole string in the buffer is fixed.
  415.         ((not (zerop (buffer-size)))
  416.          (prog1
  417.              (buffer-string)
  418.            (erase-buffer))))
  419.     ;; update incomplete-message with contents of working buffer.
  420.     (setq skk-isearch-incomplete-message (buffer-string))
  421.     ;; update echo area.
  422.     (skk-isearch-incomplete-message))))
  423.  
  424.  
  425. ;;
  426. ;; regexp search supports.
  427. ;;
  428. (defun skk-isearch-last-char (string)
  429.   (and (string-match ".\\'" string)
  430.        (string-to-char (substring string (match-beginning 0)))))
  431.  
  432. (defun skk-isearch-breakable-p (char)
  433.   (and char
  434.        (funcall skk-isearch-breakable-character-p-function char)))
  435.  
  436. (defun skk-isearch-search-string-regexp (string)
  437.   (if isearch-regexp
  438.       (let ((chars (funcall skk-isearch-breakup-string-function string))
  439.         (prev (skk-isearch-last-char isearch-string))
  440.         (result ""))
  441.     (while chars
  442.       (if (and (skk-isearch-breakable-p prev)
  443.            (skk-isearch-breakable-p (car chars)))
  444.           (setq result (concat result skk-isearch-whitespace-regexp)))
  445.       (setq result (concat result (char-to-string (car chars)))
  446.         prev (car chars)
  447.         chars (cdr chars)))
  448.     result)
  449.     string))
  450.  
  451. (defvar skk-isearch-last-mode-string "")
  452. (defvar skk-isearch-last-mode-regexp "")
  453.  
  454. (defun skk-isearch-mode-message ()
  455.   "Prepend the skk isearch mode string to `isearch-message'.  If the current
  456. mode is different from previous, remove it first."
  457.   (let ((mode-string (skk-isearch-mode-string)))
  458.     (if (string= mode-string skk-isearch-last-mode-string)
  459.     nil
  460.       (if (string-match skk-isearch-last-mode-regexp isearch-message)
  461.       (setq isearch-message (substring isearch-message (match-end 0))))
  462.       (setq skk-isearch-last-mode-string mode-string
  463.         skk-isearch-last-mode-regexp (concat "^" 
  464.                          (regexp-quote mode-string)))
  465.       (setq isearch-message (concat mode-string isearch-message)))))
  466.  
  467. (defun skk-isearch-process-search-string (string)
  468.   (isearch-process-search-string (skk-isearch-search-string-regexp string) 
  469.                  string))
  470.  
  471.  
  472. ;;
  473. ;; interactive functions.
  474. ;;
  475. (defun skk-isearch-delete-char (&rest args)
  476.   (interactive "P")
  477.   (or (with-current-buffer (get-buffer-create skk-isearch-working-buffer)
  478.     ;; following code is highly depends on internal of skk.
  479.     (if (skk-isearch-conversion-active-p)
  480.         (prog1
  481.         t
  482.           ;; now, we can't pass the universal argument within the
  483.           ;; isearch-mode.  so hard code the value `1'.
  484.           (delete-backward-char 1)
  485.           (setq skk-isearch-incomplete-message (buffer-string))
  486.           (skk-isearch-incomplete-message))))
  487.       (isearch-delete-char)))
  488.  
  489. (defun skk-isearch-kakutei (isearch-function)
  490.   "Special wrapper for skk-kakutei or newline."
  491.   (if (with-current-buffer (get-buffer-create skk-isearch-working-buffer)
  492.     ;; following code is highly depends on internal of skk.
  493.     (if (skk-isearch-conversion-active-p)
  494.         (prog1
  495.         t
  496.           (skk-isearch-skk-kakutei))))
  497.       (skk-isearch-process-search-string (skk-isearch-search-string))
  498.     (funcall isearch-function)))
  499.  
  500. (defun skk-isearch-exit (&rest args)
  501.   (interactive "P")
  502.   (skk-isearch-kakutei (function isearch-exit)))
  503.  
  504. (defun skk-isearch-newline (&rest args)
  505.   (interactive "P")
  506.   ;; following code is highly depends on internal of skk.
  507.   (if (with-current-buffer (get-buffer-create skk-isearch-working-buffer)
  508.     (if (memq (skk-isearch-current-mode) '(latin jisx0208-latin))
  509.         (prog1
  510.         t
  511.           ;; if the working buffer is latin or jisx0208-latin
  512.           ;; mode, default behaviour of C-j is set current mode
  513.           ;; to kana mode.
  514.           (skk-mode 1)
  515.           (skk-isearch-mode-message))))
  516.       (isearch-message)
  517.     (skk-isearch-kakutei (function isearch-printing-char))))
  518.  
  519. (defun skk-isearch-skk-mode (&rest args)
  520.   (interactive "P")
  521.   (skk-isearch-redo-function)
  522.   (isearch-message))
  523.  
  524. (defun skk-isearch-keyboard-quit (&rest args)
  525.   (interactive "P")
  526.   (condition-case ()
  527.       (progn
  528.     (skk-isearch-redo-function)
  529.     ;; update echo area message.
  530.     (skk-isearch-search-string))
  531.     (quit (isearch-abort))))
  532.  
  533. (defun skk-isearch-wrapper (&rest args)
  534.   (interactive "P")
  535.   (skk-isearch-redo-function)
  536.   (let ((string (skk-isearch-search-string)))
  537.     (if (null string)
  538.     ;; on the way to converting to kanji.
  539.     nil
  540.       ;; with saving value of old binding...
  541.       (let ((local-map (symbol-value skk-isearch-overriding-local-map))
  542.         (current-buffer (current-buffer)))
  543.     ;; because the overrinding local map may be buffer local, keep the
  544.     ;; current buffer, but we can't use save-excursion. ...
  545.     (unwind-protect
  546.         (progn
  547.           (set skk-isearch-overriding-local-map isearch-mode-map)
  548.           (let ((command (key-binding string)))
  549.         (if (commandp command)
  550.             ;; process a special character, such as *, |, ...
  551.             (command-execute command)
  552.           ;; just search literally.
  553.           (skk-isearch-process-search-string string) )))
  554.       ;; restore the overriding local map.
  555.       (set-buffer current-buffer)
  556.       (set skk-isearch-overriding-local-map local-map))))))
  557.  
  558. (put 'skk-isearch-wrapper 'isearch-command t)
  559. (put 'skk-isearch-keyboard-quit 'isearch-command t)
  560. (put 'skk-isearch-newline 'isearch-command t)
  561. (put 'skk-isearch-exit 'isearch-command t)
  562. (put 'skk-isearch-delete-char 'isearch-command t)
  563. (put 'isearch-other-control-char 'isearch-command t)
  564. (put 'skk-isearch-skk-mode 'isearch-command t)
  565.  
  566. (provide 'skk-isearch)
  567.  
  568. ;;; skk-isearch.el ends here
  569.